package com.conan.zone.framework.service.impl;

import java.util.List;

import com.conan.zone.framework.dao.IAbstractMapper;
import com.conan.zone.framework.model.ParamBean;
import com.conan.zone.framework.service.IAbstractService;

/**
 * 
 * @author Conan
 * 
 * @param <T>
 */
public class AbstractServiceImpl2<T extends ParamBean> implements IAbstractService<T> {
	protected IAbstractMapper<T> IAbstractMapper;

	@Override
	public String tableJson(T t, String sEcho, List<T> list) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<T> search(T t) {
		return IAbstractMapper.selectByCondition(t, t.getStartIndex(), t.getEndIndex());
	}

	@Override
	public List<T> all(T t) {
		return IAbstractMapper.selectByCondition(t, 0, Integer.MAX_VALUE);
	}

	@Override
	public int numOfTotal(T t) {
		Integer it = IAbstractMapper.countByCondition(t);
		if (it == null)
			return 0;
		return it.intValue();
	}
	
	@Override
	public int updateByPk(T t) {
		return IAbstractMapper.updateByPrimaryKey(t);
	}

	@Override
	public int deleteByPk(Long pk) {
		return IAbstractMapper.deleteByPrimaryKey(pk);
	}

	@Override
	public T selectByPk(Long pk) {
		return IAbstractMapper.selectByPrimaryKey(pk);
	}

	public IAbstractMapper<T> getIAbstractMapper() {
		return IAbstractMapper;
	}

	public void setIAbstractMapper(IAbstractMapper<T> iAbstractMapper) {
		IAbstractMapper = iAbstractMapper;
	}
	
	

}
